package com.itheima.common;

import com.itheima.enumcommon.Direction;
import com.itheima.enumcommon.EnumClass;

public class EnumDemo {

    public static void main(String[] args) {
        EnumClass a =  EnumClass.X;
        EnumClass b =  EnumClass.Y;
        System.out.println(a);
        System.out.println(a.name()); // X
        System.out.println(b.name()); // Y
        System.out.println(a.ordinal());  // 索引 0
        for ( EnumClass e : EnumClass.values()){ //遍历枚举对象 X Y Z
            System.out.println(e);
        }
    }

    public static void move(Direction direction){
        switch (direction){
            case Direction.UP:
                System.out.println("向上移动");
                break;
            case DOWN:
                System.out.println("向下移动");
                break;
            case LEFT:
                System.out.println("向左移动");
                break;
            case RIGHT:
                System.out.println("向右移动");
                break;
        }
    }
}
